//导入模块
const express=require('express');
const connection=require('../uilit/mysql');

//创建路由
const myRouter=express.Router();

//接口编写
//获取
myRouter.get('/getabc',(req,res)=>{
    const page=req.query.page;
    const count=req.query.count;
    const sql=`SELECT * FROM RESUME JOIN seeker ON resume.s_id=seeker.s_id JOIN industry_category ON resume.ind_id=industry_category.ind_id LIMIT ${(page-1)*count},${count}`;
    const sql2=`select count(*) as total from RESUME JOIN seeker ON resume.s_id=seeker.s_id JOIN industry_category ON resume.ind_id=industry_category.ind_id;`;
    connection.query(sql,(err,data)=>{
        if(err){
            console.log(err)
            res.send({error:1,msg:err})
        }else{
            connection.query(sql2,(err2,data2)=>{
                if(err2){
                    console.log(err2)
                    res.send({error:1,msg:err2})
                }else{
                    console.log(data2)
                    res.send({error:0,msg:'获取成功',data:data,total:data2[0].total})
                }
            })
        }
    })
})

//导出
module.exports=myRouter;


